<td>
<?php 
$dossierId=$currentObject->id;
$reste=0;

$SQL="SELECT
Sum(cabinet_dossier_avance.montant) as dossier_avance
FROM
cabinet_dossier_avance
WHERE
cabinet_dossier_avance.dossierId = $currentObject->id";

$rs=ew_LoadRecordset($SQL);
if ($rs && !$rs->EOF) $dossier_avance=$rs->fields['dossier_avance'];


$SQL="SELECT
Sum(cabinet_soins.montant) as soins_montant
FROM
cabinet_soins
WHERE
cabinet_soins.dossierId  = $currentObject->id";

$rs=ew_LoadRecordset($SQL);



if ($rs && !$rs->EOF) $soins_montant=$rs->fields['soins_montant'];


$reste = $soins_montant - $dossier_avance ;

if ($reste=="") $reste=0;
echo $reste;
?>

</td>




<?php 
$reste=0;
$SQL="SELECT

cabinet_soin_radios.image
FROM
cabinet_soins
INNER JOIN cabinet_soin_radios ON cabinet_soin_radios.soinId = cabinet_soins.id
WHERE
cabinet_soins.dossierId =  $currentObject->id";

$rs=ew_LoadRecordset($SQL);

while ($rs && !$rs->EOF)
{
	
	?>
	
	<a href="<?=getFilesPath("soinradios",false)."/".$rs->fields['image'];?>" class="soinimages" rel="radios_<?=$currentObject->id ?>"><img src="<?=getFilesPath("soinradios",false)."/".$rs->fields['image'];?>" width="32"></a>
	<?php 
	$rs->MoveNext();
	
}







$SQL="SELECT count(*) as cnt FROM cabinet_dent_default WHERE dossierId=$dossierId ";

//echo $SQL;

$rs=ew_LoadRecordset($SQL);

if ($rs->fields["cnt"]==0){
$GLOBALS["conn"]->BeginTrans();

$arr_dent=array("11","12","13","14","15","16","17","18","21","22","23","24","25","26","27","28","31","32","33","34","35","36","37","38","41","42","43","44","45","46","47","48");
$arr_dent_temp=array("51","52","53","54","55","61","62","63","64","65","71","72","73","74","75","81","82","83","84","85");
if ($currentObject->dentition=="Temporaire")  cabinet_setdentdefault($arr_dent_temp,$dossierId);

if ($currentObject->dentition=="Adulte") cabinet_setdentdefault($arr_dent,$dossierId);

if ($currentObject->dentition=="Mixte")
{
	cabinet_setdentdefault($arr_dent,$dossierId);
	cabinet_setdentdefault($arr_dent_temp,$dossierId);
	
}



$GLOBALS["conn"]->CommitTrans();
}
?>


